#include "FileLogger.hpp"

void FileLogger::write(){
	fileStream.write((char*)pool.pool, pool.location);
	fileStream.flush();
}

FileLogger::FileLogger(){
	Logger::instance = this;
    fileStream.open(FileLogger::getFilename(), std::ios::out | std::ios::app);
}

FileLogger::~FileLogger(){
    write();
    fileStream.close();
}

const char* FileLogger::getFilename(){
    char *filename = new char[32];
	time_t curTime = time(0);
    struct tm* _time = localtime(&curTime);
    strftime(filename, 32, "%m_%d_%y_%H_%M_%S.txt", _time);
    return filename;
}

void FileLogger::close(){
    write();
    fileStream.close();
}